import { request } from "@umijs/max";

/** 字典列表 */
export async function listDists(data: DistTypes.Query) {
  return request<API.PageResult<DistTypes.List>>("/dict/list", {
    method: "POST",
    data,
  });
}

/** 字典创建 */
export async function createDist(data: DistTypes.Create) {
  return request("/dict", {
    method: "POST",
    data,
  });
}

/** 字典更新 */
export async function updateDist(data: DistTypes.Update) {
  return request("/dict", {
    method: "PUT",
    data,
  });
}

/** 字典删除 */
export async function deleteDist(id: number) {
  return request(`/dict/${id}`, {
    method: "DELETE",
  });
}

/** 根据 typeCode 查询*/
export async function getByType(typeCode: string) {
  return request<DistTypes.InfoVO[]>(`/dict/type/${typeCode}`, {
    method: "GET",
  });
}

/** 根据 typeCode 查询*/
export async function getTreeByType(typeCode: string) {
  return request<DistTypes.TreeVO[]>(`/dict/tree/${typeCode}`, {
    method: "GET",
  });
}
